<%@page import="service.UserService"%>
<%@page import="entities.UserEntity"%>
<%@page import="service.SellerService"%>
<%@page import="entities.SellerEntity"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	String sellerName = (String) session.getAttribute("sellerName");
	String password = (String) session.getAttribute("sellerpassword");
	SellerEntity seller = new SellerEntity();
	if (sellerName == null || password == null) {
		response.sendRedirect("index.jsp");
	} else {
		seller = SellerService.confirm(sellerName, password.trim());
		if(seller == null){
			response.sendRedirect("index.jsp");
		}
	}
	String action = request.getParameter("action");
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>用户信息-<%=seller.getName()%></title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">


<script type="text/javascript" src="<%=basePath%>js/jquery.min.js">
	
</script>
<script type="text/javascript" src="<%=basePath%>js/GlobalFunction.js">
	
</script>
<script type="text/javascript" src="<%=basePath%>_seller/js/sellerInfo.js">
	
</script>
<script type="text/javascript" src="<%=basePath%>_seller/js/jQuery.timeRange.js">
	
</script>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>user/css/user.css">

</head>

<style type="text/css">
div.center {
	margin-top: 20px;
}
</style>

<body>
	<jsp:include page="header.jsp"></jsp:include>

	<div id="sellerId" style="display: none"><%=seller.getId()%></div>
	<div id="logo" style="display:none"><%=seller.getLogoURL()%></div>
	<div id="action" style="display: none;"><%=action%></div>
	<div class="center">
		<div class="leftPanel">
			<div class="userInfo" id="UserInfo">
				<ul>
					<li><a title="设置商标" href="_seller/sellerInfo.jsp?action=logo"><img
							src="<%=seller.getLogoURL()%>" alt="logo"> </a>
						<h3>
							[<%=seller.getName()%>]
						</h3>店主：<%=seller.getOwner()%> <br />
					<li><a class="name">手机号码：</a><a class="value"><%=seller.getTel()%></a>
					</li>
					<li><a class="name">地址：</a><a class="value"><%=seller.getAddress()%></a>
					</li>
					<li><a class="name">营业时间：</a><a class="value"><%=seller.getDeliverTime()%></a>
					</li>
					<li><a class="name">注册时间：</a><a class="value"><%=seller.getRegTime()%></a>
					</li>
				</ul>
			</div>

			<div class="thirdNav">
				<ul>
					<li id="logo"><a href="_seller/sellerInfo.jsp?action=logo">Logo修改</a>
					</li>
					<li id="phone"><a href="_seller/sellerInfo.jsp?action=phone">设置电话号码</a>
					</li>
					<li id="password"><a
						href="_seller/sellerInfo.jsp?action=password">设置密码</a>
					</li>
					
					<li id="info"><a href="_seller/sellerInfo.jsp?action=info">基本信息</a>
					</li>
				</ul>
			</div>
		</div>
		<div class="rightPanel">
			<%
				if ("logo".equals(action)) {
			%>
			<div class="panelTitle">
				<a>Logo设置</a>
			</div>
			<div id="altContent"></div>
			<script type="text/javascript"
				src="<%=basePath%>_seller/js/swfobject.js"></script>
			<script type="text/javascript">

			function uploadevent(status){
			     status += '';
			     $(".panelTitle").append(status);
				 switch(status){

					case '1':
						alert('保存成功!');
						//var time = new Date().getTime();
						 window.location.reload(true);
						//document.getElementById('avatar_priview').innerHTML = "头像1 : <img src='1.png?" + time + "'/> <br/> 头像2: <img src='2.png?" + time + "'/><br/> 头像3: <img src='3.png?" + time + "'/><br/> 原图: <img src='src.png?" + time + "'/>";
					break;

					case '2':
						if(confirm('js call upload')){
							return 1;
						}else{
							return 0;
						}
					break;

					case '-1':
						alert('取消!');
					break;
					case '-2':
						alert('保存失败，可能是图片太大!');
					break;

					default:
						alert(typeof(status) + ' ' + status);
				} 
			}

			var logo = $("#logo").html();
			if(logo=="null"){
				logo = "../images/default.jpg";
			}
			var flashvars = {
			  "imgUrl":logo,
			  "jsfunc":"uploadevent",
			  "pid":"75642723",
			  "uploadSrc":true,
			  "showBrow":true,
			  "showCame":true,
			  "uploadUrl":"servlet/SellerUploadLogo?sellerId="+$("#sellerId").html()
			};

			var params = {
				menu: "false",
				scale: "noScale",
				allowFullscreen: "true",
				allowScriptAccess: "always",
				wmode:"transparent",
				bgcolor: "#FFFFFF"
			};

			var attributes = {
				id:"FaustCplus"
			};

			swfobject.embedSWF("_seller/FaustCplus.swf", "altContent", "650", "500", "8.0.0", "expressInstall.swf", flashvars, params, attributes);

		</script>
			<%
				} else if ("info".equals(action)) {
			%>
			<div class="panelTitle">
				<a>基本信息设置</a>
			</div>
			<ul>
				<li><a>营业时间</a></li>
				<li><input type="text" id="DeliverTextBox" class="timeRange textBox"
					value="<%=seller.getDeliverTime()%>"></li>
				<li><a>邮箱</a> <span style="color: red;" id="EmailTips"></span>
				</li>
				<li><input type="text" id="EmailTextBox" class="textBox"
					value="<%=seller.getEmail()%>">
				</li>
				<li><a>地址</a>></li>
				<li><input type="text" id="AddressTextBox" class="textBox"
					value="<%=seller.getAddress()%>">
				</li>

				<li><a>描述</a></li>
				<li><textarea id="DecTextBox" class="textBox mulTextBox"
						rows="2" cols="20"><%=seller.getDesc()%></textarea></li>
				<li><a style="color: red;" id="ChangeInfoTips"></a></li>
				<li><input id="Button1" class="button" type="button" value="保存"
					onclick="changeSellerInfo()"></li>
			</ul>
			<%
				} else if ("phone".equals(action)) {
			%>
			<div class="panelTitle">
				<a>电话设置</a>
			</div>
			<ul>
				<li><span id="PhoneTextBox" style="display: none;"><%=seller.getTel()%></span>
				</li>
				<li><a>请输入电话号码</a></li>
				<li><input type="text" id="PhoneTextBox1" value="<%=seller.getTel() %>" class="textBox">
					</li>

				<li><a style="color: red;" id="ChangePhoneTips"></a></li>
				<li><input id="Button1" class="button" type="button" value="保存"
					onclick="changePhone()"></li>
			</ul>
			<%
				} else if ("password".equals(action)) {
			%>
			<div class="panelTitle">
				<a>密码设置</a>
			</div>
			<ul>
				<li><a>请输入新密码</a></li>
				<li><input type="password" id="PasswordTextBox1"
					class="textBox">
				</li>
				<li><a>请再次输入密码</a></li>
				<li><input type="password" id="PasswordTextBox2"
					class="textBox">
				</li>
				<li><a style="color: red;" id="ChangePasswordTips"></a></li>
				<li><input type="button" id="Button1" class="button" value="保存"
					onclick="changePassword()"></li>
			</ul>
			<%
				}
			%>
		</div>
	</div>
</body>
</html>
